package com.ext.aic.apis.agent;

import android.content.Context;

import androidx.lifecycle.LifecycleOwner;

import com.ext.aic.apis.ApiDefine;
import com.ext.aic.apis.ApiPaths;
import com.ext.aic.apis.RequestResponse;
import com.ext.aic.beans.response.IntervalResponse;
import com.ext.aic.utils.ToastyUtils;
import com.hjq.http.EasyHttp;

public class IntervalRequest {

    protected void onIntervalSuccess(int interval) {

    }

    public void request(Context context, LifecycleOwner lifecycleOwner) {
        EasyHttp.get(lifecycleOwner)
                .api(new ApiDefine(ApiPaths.agentInterval))
                .request(new RequestResponse<IntervalResponse>(context, false) {
                    @Override
                    protected void onSuccess(IntervalResponse response) {
                        if (response.getCode() == 200) {
                            onIntervalSuccess(response.getInterval());
                        } else {
                            ToastyUtils.getInstance().show(response.getMessage());
                        }
                    }
                });
    }
}
